package org.xbzheng.restful_study.dao;

import org.springframework.stereotype.Repository;
import org.xbzheng.restful_study.model.Role;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;

@Repository
public class RoleDao {

    @PersistenceContext
    private EntityManager entityManager;

    public Role save(Role role){
        return entityManager.merge(role);
    }

    public List<Role> findAll(){
        return entityManager.createQuery("select r from Role r ").getResultList();
    }
}
